home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / cross / ava-0.2.5.lha / ava-0.2.5 / src / Reports.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-03-23  |  2.4 KB  |  92 lines

  1. /* Reports.h, Uros Platise, dec. 1998 */
  2.  
  3. #ifndef __Reports
  4. #define __Reports
  5.  
  6. #include <stdlib.h>
  7. #include <stdarg.h>
  8. #include <time.h>
  9. #include "Lexer.h"
  10. #include "Preproc.h"
  11. #include "Error.h"
  12.  
  13. #define MAX_ERRORS_BEFORE_HALT    16
  14.  
  15. #define MAX_CODEWIDTH        64
  16.  
  17. class TListing{
  18. private:
  19.   PSource srclP;    /* assembler source file */
  20.   PSource dstlP;    /* listing (destination) file */
  21.   long clineNo;        /* current line number */
  22.   long addrBuf;        /* hold address of the first byte in a line in buffer */
  23.   long addrCnt;        /* address counter */
  24.   int codeWidth;    /* index from the left border */
  25.   int addrWidth;    /* width of the address column */
  26.   char codeBuf [LX_LINEBUF];    /* code buffer ... */
  27.   bool splitStr;    /* if codeBuf exceeds MAX_CODEWIDTH, splitStr=true */
  28.   bool listingEnabled;    /* if listings is not enabled in the command line,
  29.                            listing files are not created */
  30. private:
  31.   void CopyNextLine(bool addAsmSource=true);
  32.   void Unroll();  
  33. public:
  34.   TListing():listingEnabled(false){}
  35.   ~TListing(){Unroll();}
  36.   
  37.   void Create(const char* asmFname);
  38.   void Address(long addr){if (!listingEnabled){return;} addrCnt=addr;}
  39.   void GotoLine(long ln);
  40.   void Codecat(const char* code);  
  41.   void Enable(){listingEnabled=true;}
  42.   void Disable(){listingEnabled=false;}
  43.   inline bool IsEnabled(){return listingEnabled;}
  44. };
  45.  
  46. class TReports{
  47. public:
  48.   enum TGroup{None=0,Symbols=1, Segments=2,WholeGroup=3};
  49. private:
  50.   TGroup GroupMask;
  51.   int ErrorCnt;
  52.   int MaxErrors;
  53.   int verbose_level;
  54.   TFile* logfile;
  55.   time_t gt;
  56. public:
  57.   TListing listing;
  58.   enum TVerboseLevel {
  59.       VL_ALL=0, 
  60.       VL_ASM1=1, 
  61.       VL_LINK1=1, 
  62.       VL_SEG1=1, VL_SEG4=4,    /* more than 3 is debug level */
  63.       VL_SYN1=1};
  64. public:
  65.   TReports():
  66.     GroupMask(WholeGroup),ErrorCnt(0),MaxErrors(MAX_ERRORS_BEFORE_HALT),
  67.     verbose_level(0),logfile(NULL){}
  68.     
  69.   ~TReports();
  70.   
  71.   void FileStatus(int _verbose_level);
  72.   void Info(int _verbose_level, const char* fmt, ...);
  73.   void Warnning(const char* fmt, ...);
  74.   void Warnning(TGroup group, const char* fmt, ...);
  75.   void Error(global_error& error);
  76.   
  77.   void Config(TGroup _GroupMask){GroupMask|=_GroupMask;};
  78.   void Config(int _MaxErrors){MaxErrors=_MaxErrors;}
  79.   void Config(char* logFileName);
  80.   void IncVerboseLevel(){verbose_level++;}
  81.   
  82.   int ErrorCount() const {return ErrorCnt;}
  83.   inline int VerboseLevel() const {return verbose_level;}
  84.   
  85.   char* Today();
  86. };
  87.  
  88. extern TReports reports;
  89.  
  90. #endif
  91.  
  92.